﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace V2 {
    internal class Program {
        private static void Main( string[] args ) {
            //Console.WriteLine("Update Test");
            //Console.WriteLine("Success: " + SetTests.SendsUpdates());
            //Console.WriteLine();
            //Console.WriteLine("InitialState Update Test");
            //Console.WriteLine("Success: " + SetTests.BindingSendsInitialState());
            //Console.WriteLine();
            //Console.WriteLine("Partition Test");
            //Console.WriteLine("Success: " + SetPartitionTests.BasicPartitionNotice());
            //Console.WriteLine();
            //Console.WriteLine("Product Test");
            //Console.WriteLine("Success: " + SetProductTests.BasicProductNotice());
            //Console.WriteLine();
            //Console.WriteLine("Product Test w/ nulls");
            //Console.WriteLine("Success: " + SetProductTests.ProductNoticeOnTwoOrMoreLeftishJoinNulls());
            //Console.WriteLine();

            Console.WriteLine("Join");
            Console.WriteLine("Success: " + CombinationTest.QuickComboTest());
            Console.WriteLine();
            Console.WriteLine("TemplateExample");
            ValueTemplateTest.QuickTest();
            Console.WriteLine();
            
            Console.ReadKey();

            //String[] s1 = {"A", "B", "C"};
            //String[] s2 = {"1", "2", "3", "4"};
            //String[] s3 = {"a", "b", "c"};
            //String[] s4 = {"x", "y", "z"};
            //String[] s5 = {"x", "y", "z"};
            //QuickCombo( new List< IList< string > >() {s1, s2, s3, s4, s5} );
            //Console.ReadKey();
        }


        public static void QuickCombo( IList< IList< String > > list_of_lists ) {
            int[] indices = new int[list_of_lists.Count];
            int total_items = 1;

            for( int current_x = 0 ; current_x < list_of_lists.Count ; current_x++ ) {
                total_items *= list_of_lists[ current_x ].Count;
            }
            Console.WriteLine( "Total:" + total_items );

            int total_changes = 0;

            while( true ) {
                for( ; indices[ 0 ] < list_of_lists[ 0 ].Count ; indices[ 0 ]++ ) {
                    foreach( int index in indices ) Console.Write( " " + index + " " );
                    Console.WriteLine();
                    total_changes++;
                }

                indices[ 0 ] = 0;

                // increment the next value, if the next value incremented is greater than the list's count,
                // set to 0 and increment the next column
                bool was_break = false;
                for( int inner_x = 1 ; inner_x < indices.Length ; inner_x++ ) {
                    if( indices[ inner_x ] + 1 < list_of_lists[ inner_x ].Count ) {
                        indices[ inner_x ]++;
                        was_break = true;
                        break;
                    } else {
                        indices[ inner_x ] = 0;
                        continue;
                    }
                }

                if( was_break == false ) break;
            }
            Console.WriteLine( "Complete: " + total_changes + " of an expected " + total_items);
            Console.ReadKey();

        }
    }
}